<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>sliderbase.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_sliderbase.js.html">sliderbase.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2007 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Implementation of a basic slider control.
<a name="line17"></a> *
<a name="line18"></a> * Models a control that allows to select a sub-range within a given
<a name="line19"></a> * range of values using two thumbs.  The underlying range is modeled
<a name="line20"></a> * as a range model, where the min thumb points to value of the
<a name="line21"></a> * rangemodel, and the max thumb points to value + extent of the range
<a name="line22"></a> * model.
<a name="line23"></a> *
<a name="line24"></a> * The currently selected range is exposed through methods
<a name="line25"></a> * getValue() and getExtent().
<a name="line26"></a> *
<a name="line27"></a> * The reason for modelling the basic slider state as value + extent is
<a name="line28"></a> * to be able to capture both, a two-thumb slider to select a range, and
<a name="line29"></a> * a single-thumb slider to just select a value (in the latter case, extent
<a name="line30"></a> * is always zero). We provide subclasses (twothumbslider.js and slider.js)
<a name="line31"></a> * that model those special cases of this control.
<a name="line32"></a> *
<a name="line33"></a> * All rendering logic is left out, so that the subclasses can define
<a name="line34"></a> * their own rendering. To do so, the subclasses overwrite:
<a name="line35"></a> * - createDom
<a name="line36"></a> * - decorateInternal
<a name="line37"></a> * - getCssClass
<a name="line38"></a> *
<a name="line39"></a> * @author arv@google.com (Erik Arvidsson)
<a name="line40"></a> * @author reto@google.com (Reto Strobl)
<a name="line41"></a> */
<a name="line42"></a>
<a name="line43"></a>goog.provide(&#39;goog.ui.SliderBase&#39;);
<a name="line44"></a>goog.provide(&#39;goog.ui.SliderBase.AnimationFactory&#39;);
<a name="line45"></a>goog.provide(&#39;goog.ui.SliderBase.Orientation&#39;);
<a name="line46"></a>
<a name="line47"></a>goog.require(&#39;goog.Timer&#39;);
<a name="line48"></a>goog.require(&#39;goog.a11y.aria&#39;);
<a name="line49"></a>goog.require(&#39;goog.a11y.aria.Role&#39;);
<a name="line50"></a>goog.require(&#39;goog.a11y.aria.State&#39;);
<a name="line51"></a>goog.require(&#39;goog.array&#39;);
<a name="line52"></a>goog.require(&#39;goog.asserts&#39;);
<a name="line53"></a>goog.require(&#39;goog.dom&#39;);
<a name="line54"></a>goog.require(&#39;goog.dom.classes&#39;);
<a name="line55"></a>goog.require(&#39;goog.events&#39;);
<a name="line56"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line57"></a>goog.require(&#39;goog.events.KeyCodes&#39;);
<a name="line58"></a>goog.require(&#39;goog.events.KeyHandler&#39;);
<a name="line59"></a>goog.require(&#39;goog.events.MouseWheelHandler&#39;);
<a name="line60"></a>goog.require(&#39;goog.fx.AnimationParallelQueue&#39;);
<a name="line61"></a>goog.require(&#39;goog.fx.Dragger&#39;);
<a name="line62"></a>goog.require(&#39;goog.fx.Transition&#39;);
<a name="line63"></a>goog.require(&#39;goog.fx.dom.ResizeHeight&#39;);
<a name="line64"></a>goog.require(&#39;goog.fx.dom.ResizeWidth&#39;);
<a name="line65"></a>goog.require(&#39;goog.fx.dom.Slide&#39;);
<a name="line66"></a>goog.require(&#39;goog.math&#39;);
<a name="line67"></a>goog.require(&#39;goog.math.Coordinate&#39;);
<a name="line68"></a>goog.require(&#39;goog.style&#39;);
<a name="line69"></a>goog.require(&#39;goog.style.bidi&#39;);
<a name="line70"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line71"></a>goog.require(&#39;goog.ui.RangeModel&#39;);
<a name="line72"></a>
<a name="line73"></a>
<a name="line74"></a>
<a name="line75"></a>/**
<a name="line76"></a> * This creates a SliderBase object.
<a name="line77"></a> * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
<a name="line78"></a> * @constructor
<a name="line79"></a> * @extends {goog.ui.Component}
<a name="line80"></a> */
<a name="line81"></a>goog.ui.SliderBase = function(opt_domHelper) {
<a name="line82"></a>  goog.ui.Component.call(this, opt_domHelper);
<a name="line83"></a>
<a name="line84"></a>  /**
<a name="line85"></a>   * The factory to use to generate additional animations when animating to a
<a name="line86"></a>   * new value.
<a name="line87"></a>   * @type {goog.ui.SliderBase.AnimationFactory}
<a name="line88"></a>   * @private
<a name="line89"></a>   */
<a name="line90"></a>  this.additionalAnimations_ = null;
<a name="line91"></a>
<a name="line92"></a>  /**
<a name="line93"></a>   * The model for the range of the slider.
<a name="line94"></a>   * @type {!goog.ui.RangeModel}
<a name="line95"></a>   */
<a name="line96"></a>  this.rangeModel = new goog.ui.RangeModel;
<a name="line97"></a>
<a name="line98"></a>  // Don&#39;t use getHandler because it gets cleared in exitDocument.
<a name="line99"></a>  goog.events.listen(this.rangeModel, goog.ui.Component.EventType.CHANGE,
<a name="line100"></a>      this.handleRangeModelChange, false, this);
<a name="line101"></a>};
<a name="line102"></a>goog.inherits(goog.ui.SliderBase, goog.ui.Component);
<a name="line103"></a>
<a name="line104"></a>
<a name="line105"></a>/**
<a name="line106"></a> * Event types used to listen for dragging events. Note that extent drag events
<a name="line107"></a> * are also sent for single-thumb sliders, since the one thumb controls both
<a name="line108"></a> * value and extent together; in this case, they can simply be ignored.
<a name="line109"></a> * @enum {string}
<a name="line110"></a> */
<a name="line111"></a>goog.ui.SliderBase.EventType = {
<a name="line112"></a>  /** User started dragging the value thumb */
<a name="line113"></a>  DRAG_VALUE_START: goog.events.getUniqueId(&#39;dragvaluestart&#39;),
<a name="line114"></a>  /** User is done dragging the value thumb */
<a name="line115"></a>  DRAG_VALUE_END: goog.events.getUniqueId(&#39;dragvalueend&#39;),
<a name="line116"></a>  /** User started dragging the extent thumb */
<a name="line117"></a>  DRAG_EXTENT_START: goog.events.getUniqueId(&#39;dragextentstart&#39;),
<a name="line118"></a>  /** User is done dragging the extent thumb */
<a name="line119"></a>  DRAG_EXTENT_END: goog.events.getUniqueId(&#39;dragextentend&#39;),
<a name="line120"></a>  // Note that the following two events are sent twice, once for the value
<a name="line121"></a>  // dragger, and once of the extent dragger. If you need to differentiate
<a name="line122"></a>  // between the two, or if your code relies on receiving a single event per
<a name="line123"></a>  // START/END event, it should listen to one of the VALUE/EXTENT-specific
<a name="line124"></a>  // events.
<a name="line125"></a>  /** User started dragging a thumb */
<a name="line126"></a>  DRAG_START: goog.events.getUniqueId(&#39;dragstart&#39;),
<a name="line127"></a>  /** User is done dragging a thumb */
<a name="line128"></a>  DRAG_END: goog.events.getUniqueId(&#39;dragend&#39;)
<a name="line129"></a>};
<a name="line130"></a>
<a name="line131"></a>
<a name="line132"></a>/**
<a name="line133"></a> * Enum for representing the orientation of the slider.
<a name="line134"></a> *
<a name="line135"></a> * @enum {string}
<a name="line136"></a> */
<a name="line137"></a>goog.ui.SliderBase.Orientation = {
<a name="line138"></a>  VERTICAL: &#39;vertical&#39;,
<a name="line139"></a>  HORIZONTAL: &#39;horizontal&#39;
<a name="line140"></a>};
<a name="line141"></a>
<a name="line142"></a>
<a name="line143"></a>/**
<a name="line144"></a> * Orientation of the slider.
<a name="line145"></a> * @type {goog.ui.SliderBase.Orientation}
<a name="line146"></a> * @private
<a name="line147"></a> */
<a name="line148"></a>goog.ui.SliderBase.prototype.orientation_ =
<a name="line149"></a>    goog.ui.SliderBase.Orientation.HORIZONTAL;
<a name="line150"></a>
<a name="line151"></a>
<a name="line152"></a>/**
<a name="line153"></a> * When the user holds down the mouse on the slider background, the closest
<a name="line154"></a> * thumb will move in &quot;lock-step&quot; towards the mouse. This number indicates how
<a name="line155"></a> * long each step should take (in milliseconds).
<a name="line156"></a> * @type {number}
<a name="line157"></a> * @private
<a name="line158"></a> */
<a name="line159"></a>goog.ui.SliderBase.MOUSE_DOWN_INCREMENT_INTERVAL_ = 200;
<a name="line160"></a>
<a name="line161"></a>
<a name="line162"></a>/**
<a name="line163"></a> * How long the animations should take (in milliseconds).
<a name="line164"></a> * @type {number}
<a name="line165"></a> * @private
<a name="line166"></a> */
<a name="line167"></a>goog.ui.SliderBase.ANIMATION_INTERVAL_ = 100;
<a name="line168"></a>
<a name="line169"></a>
<a name="line170"></a>/**
<a name="line171"></a> * The underlying range model
<a name="line172"></a> * @type {goog.ui.RangeModel}
<a name="line173"></a> * @protected
<a name="line174"></a> */
<a name="line175"></a>goog.ui.SliderBase.prototype.rangeModel;
<a name="line176"></a>
<a name="line177"></a>
<a name="line178"></a>/**
<a name="line179"></a> * The minThumb dom-element, pointing to the start of the selected range.
<a name="line180"></a> * @type {HTMLDivElement}
<a name="line181"></a> * @protected
<a name="line182"></a> */
<a name="line183"></a>goog.ui.SliderBase.prototype.valueThumb;
<a name="line184"></a>
<a name="line185"></a>
<a name="line186"></a>/**
<a name="line187"></a> * The maxThumb dom-element, pointing to the end of the selected range.
<a name="line188"></a> * @type {HTMLDivElement}
<a name="line189"></a> * @protected
<a name="line190"></a> */
<a name="line191"></a>goog.ui.SliderBase.prototype.extentThumb;
<a name="line192"></a>
<a name="line193"></a>
<a name="line194"></a>/**
<a name="line195"></a> * The dom-element highlighting the selected range.
<a name="line196"></a> * @type {HTMLDivElement}
<a name="line197"></a> * @protected
<a name="line198"></a> */
<a name="line199"></a>goog.ui.SliderBase.prototype.rangeHighlight;
<a name="line200"></a>
<a name="line201"></a>
<a name="line202"></a>/**
<a name="line203"></a> * The thumb that we should be moving (only relevant when timed move is active).
<a name="line204"></a> * @type {HTMLDivElement}
<a name="line205"></a> * @private
<a name="line206"></a> */
<a name="line207"></a>goog.ui.SliderBase.prototype.thumbToMove_;
<a name="line208"></a>
<a name="line209"></a>
<a name="line210"></a>/**
<a name="line211"></a> * The object handling keyboard events.
<a name="line212"></a> * @type {goog.events.KeyHandler}
<a name="line213"></a> * @private
<a name="line214"></a> */
<a name="line215"></a>goog.ui.SliderBase.prototype.keyHandler_;
<a name="line216"></a>
<a name="line217"></a>
<a name="line218"></a>/**
<a name="line219"></a> * The object handling mouse wheel events.
<a name="line220"></a> * @type {goog.events.MouseWheelHandler}
<a name="line221"></a> * @private
<a name="line222"></a> */
<a name="line223"></a>goog.ui.SliderBase.prototype.mouseWheelHandler_;
<a name="line224"></a>
<a name="line225"></a>
<a name="line226"></a>/**
<a name="line227"></a> * The Dragger for dragging the valueThumb.
<a name="line228"></a> * @type {goog.fx.Dragger}
<a name="line229"></a> * @private
<a name="line230"></a> */
<a name="line231"></a>goog.ui.SliderBase.prototype.valueDragger_;
<a name="line232"></a>
<a name="line233"></a>
<a name="line234"></a>/**
<a name="line235"></a> * The Dragger for dragging the extentThumb.
<a name="line236"></a> * @type {goog.fx.Dragger}
<a name="line237"></a> * @private
<a name="line238"></a> */
<a name="line239"></a>goog.ui.SliderBase.prototype.extentDragger_;
<a name="line240"></a>
<a name="line241"></a>
<a name="line242"></a>/**
<a name="line243"></a> * If we are currently animating the thumb.
<a name="line244"></a> * @private
<a name="line245"></a> * @type {boolean}
<a name="line246"></a> */
<a name="line247"></a>goog.ui.SliderBase.prototype.isAnimating_ = false;
<a name="line248"></a>
<a name="line249"></a>
<a name="line250"></a>/**
<a name="line251"></a> * Whether clicking on the backgtround should move directly to that point.
<a name="line252"></a> * @private
<a name="line253"></a> * @type {boolean}
<a name="line254"></a> */
<a name="line255"></a>goog.ui.SliderBase.prototype.moveToPointEnabled_ = false;
<a name="line256"></a>
<a name="line257"></a>
<a name="line258"></a>/**
<a name="line259"></a> * The amount to increment/decrement for page up/down as well as when holding
<a name="line260"></a> * down the mouse button on the background.
<a name="line261"></a> * @private
<a name="line262"></a> * @type {number}
<a name="line263"></a> */
<a name="line264"></a>goog.ui.SliderBase.prototype.blockIncrement_ = 10;
<a name="line265"></a>
<a name="line266"></a>
<a name="line267"></a>/**
<a name="line268"></a> * The minimal extent. The class will ensure that the extent cannot shrink
<a name="line269"></a> * to a value smaller than minExtent.
<a name="line270"></a> * @private
<a name="line271"></a> * @type {number}
<a name="line272"></a> */
<a name="line273"></a>goog.ui.SliderBase.prototype.minExtent_ = 0;
<a name="line274"></a>
<a name="line275"></a>
<a name="line276"></a>/**
<a name="line277"></a> * Whether the slider should handle mouse wheel events.
<a name="line278"></a> * @private
<a name="line279"></a> * @type {boolean}
<a name="line280"></a> */
<a name="line281"></a>goog.ui.SliderBase.prototype.isHandleMouseWheel_ = true;
<a name="line282"></a>
<a name="line283"></a>
<a name="line284"></a>/**
<a name="line285"></a> * Whether the slider is enabled or not.
<a name="line286"></a> * @private
<a name="line287"></a> * @type {boolean}
<a name="line288"></a> */
<a name="line289"></a>goog.ui.SliderBase.prototype.enabled_ = true;
<a name="line290"></a>
<a name="line291"></a>
<a name="line292"></a>/**
<a name="line293"></a> * Whether the slider implements the changes described in http://b/6324964,
<a name="line294"></a> * making it truly RTL.  This is a temporary flag to allow clients to transition
<a name="line295"></a> * to the new behavior at their convenience.  At some point it will be the
<a name="line296"></a> * default.
<a name="line297"></a> * @type {boolean}
<a name="line298"></a> * @private
<a name="line299"></a> */
<a name="line300"></a>goog.ui.SliderBase.prototype.flipForRtl_ = false;
<a name="line301"></a>
<a name="line302"></a>
<a name="line303"></a>/**
<a name="line304"></a> * Enables/disables true RTL behavior.  This should be called immediately after
<a name="line305"></a> * construction.  This is a temporary flag to allow clients to transition
<a name="line306"></a> * to the new behavior at their convenience.  At some point it will be the
<a name="line307"></a> * default.
<a name="line308"></a> * @param {boolean} flipForRtl True if the slider should be flipped for RTL,
<a name="line309"></a> *     false otherwise.
<a name="line310"></a> */
<a name="line311"></a>goog.ui.SliderBase.prototype.enableFlipForRtl = function(flipForRtl) {
<a name="line312"></a>  this.flipForRtl_ = flipForRtl;
<a name="line313"></a>};
<a name="line314"></a>
<a name="line315"></a>
<a name="line316"></a>// TODO: Make this return a base CSS class (without orientation), in subclasses.
<a name="line317"></a>/**
<a name="line318"></a> * Returns the CSS class applied to the slider element for the given
<a name="line319"></a> * orientation. Subclasses must override this method.
<a name="line320"></a> * @param {goog.ui.SliderBase.Orientation} orient The orientation.
<a name="line321"></a> * @return {string} The CSS class applied to slider elements.
<a name="line322"></a> * @protected
<a name="line323"></a> */
<a name="line324"></a>goog.ui.SliderBase.prototype.getCssClass = goog.abstractMethod;
<a name="line325"></a>
<a name="line326"></a>
<a name="line327"></a>/** @override */
<a name="line328"></a>goog.ui.SliderBase.prototype.createDom = function() {
<a name="line329"></a>  goog.ui.SliderBase.superClass_.createDom.call(this);
<a name="line330"></a>  var element =
<a name="line331"></a>      this.getDomHelper().createDom(&#39;div&#39;, this.getCssClass(this.orientation_));
<a name="line332"></a>  this.decorateInternal(element);
<a name="line333"></a>};
<a name="line334"></a>
<a name="line335"></a>
<a name="line336"></a>/**
<a name="line337"></a> * Subclasses must implement this method and set the valueThumb and
<a name="line338"></a> * extentThumb to non-null values. They can also set the rangeHighlight
<a name="line339"></a> * element if a range highlight is desired.
<a name="line340"></a> * @type {function() : void}
<a name="line341"></a> * @protected
<a name="line342"></a> */
<a name="line343"></a>goog.ui.SliderBase.prototype.createThumbs = goog.abstractMethod;
<a name="line344"></a>
<a name="line345"></a>
<a name="line346"></a>/**
<a name="line347"></a> * CSS class name applied to the slider while its thumbs are being dragged.
<a name="line348"></a> * @type {string}
<a name="line349"></a> * @private
<a name="line350"></a> */
<a name="line351"></a>goog.ui.SliderBase.SLIDER_DRAGGING_CSS_CLASS_ =
<a name="line352"></a>    goog.getCssName(&#39;goog-slider-dragging&#39;);
<a name="line353"></a>
<a name="line354"></a>
<a name="line355"></a>/**
<a name="line356"></a> * CSS class name applied to a thumb while it&#39;s being dragged.
<a name="line357"></a> * @type {string}
<a name="line358"></a> * @private
<a name="line359"></a> */
<a name="line360"></a>goog.ui.SliderBase.THUMB_DRAGGING_CSS_CLASS_ =
<a name="line361"></a>    goog.getCssName(&#39;goog-slider-thumb-dragging&#39;);
<a name="line362"></a>
<a name="line363"></a>
<a name="line364"></a>/**
<a name="line365"></a> * CSS class name applied when the slider is disabled.
<a name="line366"></a> * @type {string}
<a name="line367"></a> * @private
<a name="line368"></a> */
<a name="line369"></a>goog.ui.SliderBase.DISABLED_CSS_CLASS_ =
<a name="line370"></a>    goog.getCssName(&#39;goog-slider-disabled&#39;);
<a name="line371"></a>
<a name="line372"></a>
<a name="line373"></a>/** @override */
<a name="line374"></a>goog.ui.SliderBase.prototype.decorateInternal = function(element) {
<a name="line375"></a>  goog.ui.SliderBase.superClass_.decorateInternal.call(this, element);
<a name="line376"></a>  goog.dom.classes.add(element, this.getCssClass(this.orientation_));
<a name="line377"></a>  this.createThumbs();
<a name="line378"></a>  this.setAriaRoles();
<a name="line379"></a>};
<a name="line380"></a>
<a name="line381"></a>
<a name="line382"></a>/**
<a name="line383"></a> * Called when the DOM for the component is for sure in the document.
<a name="line384"></a> * Subclasses should override this method to set this element&#39;s role.
<a name="line385"></a> * @override
<a name="line386"></a> */
<a name="line387"></a>goog.ui.SliderBase.prototype.enterDocument = function() {
<a name="line388"></a>  goog.ui.SliderBase.superClass_.enterDocument.call(this);
<a name="line389"></a>
<a name="line390"></a>  // Attach the events
<a name="line391"></a>  this.valueDragger_ = new goog.fx.Dragger(this.valueThumb);
<a name="line392"></a>  this.extentDragger_ = new goog.fx.Dragger(this.extentThumb);
<a name="line393"></a>  this.valueDragger_.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line394"></a>  this.extentDragger_.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line395"></a>
<a name="line396"></a>  // The slider is handling the positioning so make the defaultActions empty.
<a name="line397"></a>  this.valueDragger_.defaultAction = this.extentDragger_.defaultAction =
<a name="line398"></a>      goog.nullFunction;
<a name="line399"></a>  this.keyHandler_ = new goog.events.KeyHandler(this.getElement());
<a name="line400"></a>  this.enableEventHandlers_(true);
<a name="line401"></a>
<a name="line402"></a>  this.getElement().tabIndex = 0;
<a name="line403"></a>  this.updateUi_();
<a name="line404"></a>};
<a name="line405"></a>
<a name="line406"></a>
<a name="line407"></a>/**
<a name="line408"></a> * Attaches/Detaches the event handlers on the slider.
<a name="line409"></a> * @param {boolean} enable Whether to attach or detach the event handlers.
<a name="line410"></a> * @private
<a name="line411"></a> */
<a name="line412"></a>goog.ui.SliderBase.prototype.enableEventHandlers_ = function(enable) {
<a name="line413"></a>  if (enable) {
<a name="line414"></a>    this.getHandler().
<a name="line415"></a>        listen(this.valueDragger_, goog.fx.Dragger.EventType.BEFOREDRAG,
<a name="line416"></a>            this.handleBeforeDrag_).
<a name="line417"></a>        listen(this.extentDragger_, goog.fx.Dragger.EventType.BEFOREDRAG,
<a name="line418"></a>            this.handleBeforeDrag_).
<a name="line419"></a>        listen(this.valueDragger_,
<a name="line420"></a>            [goog.fx.Dragger.EventType.START, goog.fx.Dragger.EventType.END],
<a name="line421"></a>            this.handleThumbDragStartEnd_).
<a name="line422"></a>        listen(this.extentDragger_,
<a name="line423"></a>            [goog.fx.Dragger.EventType.START, goog.fx.Dragger.EventType.END],
<a name="line424"></a>            this.handleThumbDragStartEnd_).
<a name="line425"></a>        listen(this.keyHandler_, goog.events.KeyHandler.EventType.KEY,
<a name="line426"></a>            this.handleKeyDown_).
<a name="line427"></a>        listen(this.getElement(), goog.events.EventType.MOUSEDOWN,
<a name="line428"></a>            this.handleMouseDown_);
<a name="line429"></a>    if (this.isHandleMouseWheel()) {
<a name="line430"></a>      this.enableMouseWheelHandling_(true);
<a name="line431"></a>    }
<a name="line432"></a>  } else {
<a name="line433"></a>    this.getHandler().
<a name="line434"></a>        unlisten(this.valueDragger_, goog.fx.Dragger.EventType.BEFOREDRAG,
<a name="line435"></a>            this.handleBeforeDrag_).
<a name="line436"></a>        unlisten(this.extentDragger_, goog.fx.Dragger.EventType.BEFOREDRAG,
<a name="line437"></a>            this.handleBeforeDrag_).
<a name="line438"></a>        unlisten(this.valueDragger_,
<a name="line439"></a>            [goog.fx.Dragger.EventType.START, goog.fx.Dragger.EventType.END],
<a name="line440"></a>            this.handleThumbDragStartEnd_).
<a name="line441"></a>        unlisten(this.extentDragger_,
<a name="line442"></a>            [goog.fx.Dragger.EventType.START, goog.fx.Dragger.EventType.END],
<a name="line443"></a>            this.handleThumbDragStartEnd_).
<a name="line444"></a>        unlisten(this.keyHandler_, goog.events.KeyHandler.EventType.KEY,
<a name="line445"></a>            this.handleKeyDown_).
<a name="line446"></a>        unlisten(this.getElement(), goog.events.EventType.MOUSEDOWN,
<a name="line447"></a>            this.handleMouseDown_);
<a name="line448"></a>    if (this.isHandleMouseWheel()) {
<a name="line449"></a>      this.enableMouseWheelHandling_(false);
<a name="line450"></a>    }
<a name="line451"></a>  }
<a name="line452"></a>};
<a name="line453"></a>
<a name="line454"></a>
<a name="line455"></a>/** @override */
<a name="line456"></a>goog.ui.SliderBase.prototype.exitDocument = function() {
<a name="line457"></a>  goog.base(this, &#39;exitDocument&#39;);
<a name="line458"></a>  goog.disposeAll(this.valueDragger_, this.extentDragger_, this.keyHandler_,
<a name="line459"></a>                  this.mouseWheelHandler_);
<a name="line460"></a>};
<a name="line461"></a>
<a name="line462"></a>
<a name="line463"></a>/**
<a name="line464"></a> * Handler for the before drag event. We use the event properties to determine
<a name="line465"></a> * the new value.
<a name="line466"></a> * @param {goog.fx.DragEvent} e  The drag event used to drag the thumb.
<a name="line467"></a> * @private
<a name="line468"></a> */
<a name="line469"></a>goog.ui.SliderBase.prototype.handleBeforeDrag_ = function(e) {
<a name="line470"></a>  var thumbToDrag = e.dragger == this.valueDragger_ ?
<a name="line471"></a>      this.valueThumb : this.extentThumb;
<a name="line472"></a>  var value;
<a name="line473"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line474"></a>    var availHeight = this.getElement().clientHeight - thumbToDrag.offsetHeight;
<a name="line475"></a>    value = (availHeight - e.top) / availHeight *
<a name="line476"></a>        (this.getMaximum() - this.getMinimum()) + this.getMinimum();
<a name="line477"></a>  } else {
<a name="line478"></a>    var availWidth = this.getElement().clientWidth - thumbToDrag.offsetWidth;
<a name="line479"></a>    value = (e.left / availWidth) * (this.getMaximum() - this.getMinimum()) +
<a name="line480"></a>        this.getMinimum();
<a name="line481"></a>  }
<a name="line482"></a>  // Bind the value within valid range before calling setThumbPosition_.
<a name="line483"></a>  // This is necessary because setThumbPosition_ is a no-op for values outside
<a name="line484"></a>  // of the legal range. For drag operations, we want the handle to snap to the
<a name="line485"></a>  // last valid value instead of remaining at the previous position.
<a name="line486"></a>  if (e.dragger == this.valueDragger_) {
<a name="line487"></a>    value = Math.min(Math.max(value, this.getMinimum()),
<a name="line488"></a>        this.getValue() + this.getExtent());
<a name="line489"></a>  } else {
<a name="line490"></a>    value = Math.min(Math.max(value, this.getValue()), this.getMaximum());
<a name="line491"></a>  }
<a name="line492"></a>  this.setThumbPosition_(thumbToDrag, value);
<a name="line493"></a>};
<a name="line494"></a>
<a name="line495"></a>
<a name="line496"></a>/**
<a name="line497"></a> * Handler for the start/end drag event on the thumgs. Adds/removes
<a name="line498"></a> * the &quot;-dragging&quot; CSS classes on the slider and thumb.
<a name="line499"></a> * @param {goog.fx.DragEvent} e The drag event used to drag the thumb.
<a name="line500"></a> * @private
<a name="line501"></a> */
<a name="line502"></a>goog.ui.SliderBase.prototype.handleThumbDragStartEnd_ = function(e) {
<a name="line503"></a>  var isDragStart = e.type == goog.fx.Dragger.EventType.START;
<a name="line504"></a>  goog.dom.classes.enable(this.getElement(),
<a name="line505"></a>      goog.ui.SliderBase.SLIDER_DRAGGING_CSS_CLASS_, isDragStart);
<a name="line506"></a>  goog.dom.classes.enable(e.target.handle,
<a name="line507"></a>      goog.ui.SliderBase.THUMB_DRAGGING_CSS_CLASS_, isDragStart);
<a name="line508"></a>  var isValueDragger = e.dragger == this.valueDragger_;
<a name="line509"></a>  if (isDragStart) {
<a name="line510"></a>    this.dispatchEvent(goog.ui.SliderBase.EventType.DRAG_START);
<a name="line511"></a>    this.dispatchEvent(isValueDragger ?
<a name="line512"></a>        goog.ui.SliderBase.EventType.DRAG_VALUE_START :
<a name="line513"></a>        goog.ui.SliderBase.EventType.DRAG_EXTENT_START);
<a name="line514"></a>  } else {
<a name="line515"></a>    this.dispatchEvent(goog.ui.SliderBase.EventType.DRAG_END);
<a name="line516"></a>    this.dispatchEvent(isValueDragger ?
<a name="line517"></a>        goog.ui.SliderBase.EventType.DRAG_VALUE_END :
<a name="line518"></a>        goog.ui.SliderBase.EventType.DRAG_EXTENT_END);
<a name="line519"></a>  }
<a name="line520"></a>};
<a name="line521"></a>
<a name="line522"></a>
<a name="line523"></a>/**
<a name="line524"></a> * Event handler for the key down event. This is used to update the value
<a name="line525"></a> * based on the key pressed.
<a name="line526"></a> * @param {goog.events.KeyEvent} e  The keyboard event object.
<a name="line527"></a> * @private
<a name="line528"></a> */
<a name="line529"></a>goog.ui.SliderBase.prototype.handleKeyDown_ = function(e) {
<a name="line530"></a>  var handled = true;
<a name="line531"></a>  switch (e.keyCode) {
<a name="line532"></a>    case goog.events.KeyCodes.HOME:
<a name="line533"></a>      this.animatedSetValue(this.getMinimum());
<a name="line534"></a>      break;
<a name="line535"></a>    case goog.events.KeyCodes.END:
<a name="line536"></a>      this.animatedSetValue(this.getMaximum());
<a name="line537"></a>      break;
<a name="line538"></a>    case goog.events.KeyCodes.PAGE_UP:
<a name="line539"></a>      this.moveThumbs(this.getBlockIncrement());
<a name="line540"></a>      break;
<a name="line541"></a>    case goog.events.KeyCodes.PAGE_DOWN:
<a name="line542"></a>      this.moveThumbs(-this.getBlockIncrement());
<a name="line543"></a>      break;
<a name="line544"></a>    case goog.events.KeyCodes.LEFT:
<a name="line545"></a>      var sign = this.flipForRtl_ &amp;&amp; this.isRightToLeft() ? 1 : -1;
<a name="line546"></a>      this.moveThumbs(e.shiftKey ?
<a name="line547"></a>          sign * this.getBlockIncrement() : sign * this.getUnitIncrement());
<a name="line548"></a>      break;
<a name="line549"></a>    case goog.events.KeyCodes.DOWN:
<a name="line550"></a>      this.moveThumbs(e.shiftKey ?
<a name="line551"></a>          -this.getBlockIncrement() : -this.getUnitIncrement());
<a name="line552"></a>      break;
<a name="line553"></a>    case goog.events.KeyCodes.RIGHT:
<a name="line554"></a>      var sign = this.flipForRtl_ &amp;&amp; this.isRightToLeft() ? -1 : 1;
<a name="line555"></a>      this.moveThumbs(e.shiftKey ?
<a name="line556"></a>          sign * this.getBlockIncrement() : sign * this.getUnitIncrement());
<a name="line557"></a>      break;
<a name="line558"></a>    case goog.events.KeyCodes.UP:
<a name="line559"></a>      this.moveThumbs(e.shiftKey ?
<a name="line560"></a>          this.getBlockIncrement() : this.getUnitIncrement());
<a name="line561"></a>      break;
<a name="line562"></a>
<a name="line563"></a>    default:
<a name="line564"></a>      handled = false;
<a name="line565"></a>  }
<a name="line566"></a>
<a name="line567"></a>  if (handled) {
<a name="line568"></a>    e.preventDefault();
<a name="line569"></a>  }
<a name="line570"></a>};
<a name="line571"></a>
<a name="line572"></a>
<a name="line573"></a>/**
<a name="line574"></a> * Handler for the mouse down event.
<a name="line575"></a> * @param {goog.events.Event} e  The mouse event object.
<a name="line576"></a> * @private
<a name="line577"></a> */
<a name="line578"></a>goog.ui.SliderBase.prototype.handleMouseDown_ = function(e) {
<a name="line579"></a>  if (this.getElement().focus) {
<a name="line580"></a>    this.getElement().focus();
<a name="line581"></a>  }
<a name="line582"></a>
<a name="line583"></a>  // Known Element.
<a name="line584"></a>  var target = /** @type {Element} */ (e.target);
<a name="line585"></a>
<a name="line586"></a>  if (!goog.dom.contains(this.valueThumb, target) &amp;&amp;
<a name="line587"></a>      !goog.dom.contains(this.extentThumb, target)) {
<a name="line588"></a>    if (this.moveToPointEnabled_) {
<a name="line589"></a>      // just set the value directly based on the position of the click
<a name="line590"></a>      this.animatedSetValue(this.getValueFromMousePosition(e));
<a name="line591"></a>    } else {
<a name="line592"></a>      // start a timer that incrementally moves the handle
<a name="line593"></a>      this.startBlockIncrementing_(e);
<a name="line594"></a>    }
<a name="line595"></a>  }
<a name="line596"></a>};
<a name="line597"></a>
<a name="line598"></a>
<a name="line599"></a>/**
<a name="line600"></a> * Handler for the mouse wheel event.
<a name="line601"></a> * @param {goog.events.MouseWheelEvent} e  The mouse wheel event object.
<a name="line602"></a> * @private
<a name="line603"></a> */
<a name="line604"></a>goog.ui.SliderBase.prototype.handleMouseWheel_ = function(e) {
<a name="line605"></a>  // Just move one unit increment per mouse wheel event
<a name="line606"></a>  var direction = e.detail &gt; 0 ? -1 : 1;
<a name="line607"></a>  this.moveThumbs(direction * this.getUnitIncrement());
<a name="line608"></a>  e.preventDefault();
<a name="line609"></a>};
<a name="line610"></a>
<a name="line611"></a>
<a name="line612"></a>/**
<a name="line613"></a> * Starts the animation that causes the thumb to increment/decrement by the
<a name="line614"></a> * block increment when the user presses down on the background.
<a name="line615"></a> * @param {goog.events.Event} e  The mouse event object.
<a name="line616"></a> * @private
<a name="line617"></a> */
<a name="line618"></a>goog.ui.SliderBase.prototype.startBlockIncrementing_ = function(e) {
<a name="line619"></a>  this.storeMousePos_(e);
<a name="line620"></a>  this.thumbToMove_ = this.getClosestThumb_(this.getValueFromMousePosition(e));
<a name="line621"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line622"></a>    this.incrementing_ = this.lastMousePosition_ &lt; this.thumbToMove_.offsetTop;
<a name="line623"></a>  } else {
<a name="line624"></a>    this.incrementing_ = this.lastMousePosition_ &gt;
<a name="line625"></a>                         this.getOffsetStart_(this.thumbToMove_) +
<a name="line626"></a>                         this.thumbToMove_.offsetWidth;
<a name="line627"></a>  }
<a name="line628"></a>
<a name="line629"></a>  var doc = goog.dom.getOwnerDocument(this.getElement());
<a name="line630"></a>  this.getHandler().
<a name="line631"></a>      listen(doc, goog.events.EventType.MOUSEUP,
<a name="line632"></a>          this.stopBlockIncrementing_, true).
<a name="line633"></a>      listen(this.getElement(), goog.events.EventType.MOUSEMOVE,
<a name="line634"></a>          this.storeMousePos_);
<a name="line635"></a>
<a name="line636"></a>  if (!this.incTimer_) {
<a name="line637"></a>    this.incTimer_ = new goog.Timer(
<a name="line638"></a>        goog.ui.SliderBase.MOUSE_DOWN_INCREMENT_INTERVAL_);
<a name="line639"></a>    this.getHandler().listen(this.incTimer_, goog.Timer.TICK,
<a name="line640"></a>        this.handleTimerTick_);
<a name="line641"></a>  }
<a name="line642"></a>  this.handleTimerTick_();
<a name="line643"></a>  this.incTimer_.start();
<a name="line644"></a>};
<a name="line645"></a>
<a name="line646"></a>
<a name="line647"></a>/**
<a name="line648"></a> * Handler for the tick event dispatched by the timer used to update the value
<a name="line649"></a> * in a block increment. This is also called directly from
<a name="line650"></a> * startBlockIncrementing_.
<a name="line651"></a> * @private
<a name="line652"></a> */
<a name="line653"></a>goog.ui.SliderBase.prototype.handleTimerTick_ = function() {
<a name="line654"></a>  var value;
<a name="line655"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line656"></a>    var mouseY = this.lastMousePosition_;
<a name="line657"></a>    var thumbY = this.thumbToMove_.offsetTop;
<a name="line658"></a>    if (this.incrementing_) {
<a name="line659"></a>      if (mouseY &lt; thumbY) {
<a name="line660"></a>        value = this.getThumbPosition_(this.thumbToMove_) +
<a name="line661"></a>            this.getBlockIncrement();
<a name="line662"></a>      }
<a name="line663"></a>    } else {
<a name="line664"></a>      var thumbH = this.thumbToMove_.offsetHeight;
<a name="line665"></a>      if (mouseY &gt; thumbY + thumbH) {
<a name="line666"></a>        value = this.getThumbPosition_(this.thumbToMove_) -
<a name="line667"></a>            this.getBlockIncrement();
<a name="line668"></a>      }
<a name="line669"></a>    }
<a name="line670"></a>  } else {
<a name="line671"></a>    var mouseX = this.lastMousePosition_;
<a name="line672"></a>    var thumbX = this.getOffsetStart_(this.thumbToMove_);
<a name="line673"></a>    if (this.incrementing_) {
<a name="line674"></a>      var thumbW = this.thumbToMove_.offsetWidth;
<a name="line675"></a>      if (mouseX &gt; thumbX + thumbW) {
<a name="line676"></a>        value = this.getThumbPosition_(this.thumbToMove_) +
<a name="line677"></a>            this.getBlockIncrement();
<a name="line678"></a>      }
<a name="line679"></a>    } else {
<a name="line680"></a>      if (mouseX &lt; thumbX) {
<a name="line681"></a>        value = this.getThumbPosition_(this.thumbToMove_) -
<a name="line682"></a>            this.getBlockIncrement();
<a name="line683"></a>      }
<a name="line684"></a>    }
<a name="line685"></a>  }
<a name="line686"></a>
<a name="line687"></a>  if (goog.isDef(value)) { // not all code paths sets the value variable
<a name="line688"></a>    this.setThumbPosition_(this.thumbToMove_, value);
<a name="line689"></a>  }
<a name="line690"></a>};
<a name="line691"></a>
<a name="line692"></a>
<a name="line693"></a>/**
<a name="line694"></a> * Stops the block incrementing animation and unlistens the necessary
<a name="line695"></a> * event handlers.
<a name="line696"></a> * @private
<a name="line697"></a> */
<a name="line698"></a>goog.ui.SliderBase.prototype.stopBlockIncrementing_ = function() {
<a name="line699"></a>  if (this.incTimer_) {
<a name="line700"></a>    this.incTimer_.stop();
<a name="line701"></a>  }
<a name="line702"></a>
<a name="line703"></a>  var doc = goog.dom.getOwnerDocument(this.getElement());
<a name="line704"></a>  this.getHandler().
<a name="line705"></a>      unlisten(doc, goog.events.EventType.MOUSEUP,
<a name="line706"></a>          this.stopBlockIncrementing_, true).
<a name="line707"></a>      unlisten(this.getElement(), goog.events.EventType.MOUSEMOVE,
<a name="line708"></a>          this.storeMousePos_);
<a name="line709"></a>};
<a name="line710"></a>
<a name="line711"></a>
<a name="line712"></a>/**
<a name="line713"></a> * Returns the relative mouse position to the slider.
<a name="line714"></a> * @param {goog.events.Event} e  The mouse event object.
<a name="line715"></a> * @return {number} The relative mouse position to the slider.
<a name="line716"></a> * @private
<a name="line717"></a> */
<a name="line718"></a>goog.ui.SliderBase.prototype.getRelativeMousePos_ = function(e) {
<a name="line719"></a>  var coord = goog.style.getRelativePosition(e, this.getElement());
<a name="line720"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line721"></a>    return coord.y;
<a name="line722"></a>  } else {
<a name="line723"></a>    if (this.flipForRtl_ &amp;&amp; this.isRightToLeft()) {
<a name="line724"></a>      return this.getElement().clientWidth - coord.x;
<a name="line725"></a>    } else {
<a name="line726"></a>      return coord.x;
<a name="line727"></a>    }
<a name="line728"></a>  }
<a name="line729"></a>};
<a name="line730"></a>
<a name="line731"></a>
<a name="line732"></a>/**
<a name="line733"></a> * Stores the current mouse position so that it can be used in the timer.
<a name="line734"></a> * @param {goog.events.Event} e  The mouse event object.
<a name="line735"></a> * @private
<a name="line736"></a> */
<a name="line737"></a>goog.ui.SliderBase.prototype.storeMousePos_ = function(e) {
<a name="line738"></a>  this.lastMousePosition_ = this.getRelativeMousePos_(e);
<a name="line739"></a>};
<a name="line740"></a>
<a name="line741"></a>
<a name="line742"></a>/**
<a name="line743"></a> * Returns the value to use for the current mouse position
<a name="line744"></a> * @param {goog.events.Event} e  The mouse event object.
<a name="line745"></a> * @return {number} The value that this mouse position represents.
<a name="line746"></a> */
<a name="line747"></a>goog.ui.SliderBase.prototype.getValueFromMousePosition = function(e) {
<a name="line748"></a>  var min = this.getMinimum();
<a name="line749"></a>  var max = this.getMaximum();
<a name="line750"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line751"></a>    var thumbH = this.valueThumb.offsetHeight;
<a name="line752"></a>    var availH = this.getElement().clientHeight - thumbH;
<a name="line753"></a>    var y = this.getRelativeMousePos_(e) - thumbH / 2;
<a name="line754"></a>    return (max - min) * (availH - y) / availH + min;
<a name="line755"></a>  } else {
<a name="line756"></a>    var thumbW = this.valueThumb.offsetWidth;
<a name="line757"></a>    var availW = this.getElement().clientWidth - thumbW;
<a name="line758"></a>    var x = this.getRelativeMousePos_(e) - thumbW / 2;
<a name="line759"></a>    return (max - min) * x / availW + min;
<a name="line760"></a>  }
<a name="line761"></a>};
<a name="line762"></a>
<a name="line763"></a>
<a name="line764"></a>/**
<a name="line765"></a> * @deprecated Since 25-June-2012. Use public method getValueFromMousePosition.
<a name="line766"></a> * @private
<a name="line767"></a> */
<a name="line768"></a>goog.ui.SliderBase.prototype.getValueFromMousePosition_ =
<a name="line769"></a>    goog.ui.SliderBase.prototype.getValueFromMousePosition;
<a name="line770"></a>
<a name="line771"></a>
<a name="line772"></a>/**
<a name="line773"></a> * @param {HTMLDivElement} thumb  The thumb object.
<a name="line774"></a> * @return {number} The position of the specified thumb.
<a name="line775"></a> * @private
<a name="line776"></a> */
<a name="line777"></a>goog.ui.SliderBase.prototype.getThumbPosition_ = function(thumb) {
<a name="line778"></a>  if (thumb == this.valueThumb) {
<a name="line779"></a>    return this.rangeModel.getValue();
<a name="line780"></a>  } else if (thumb == this.extentThumb) {
<a name="line781"></a>    return this.rangeModel.getValue() + this.rangeModel.getExtent();
<a name="line782"></a>  } else {
<a name="line783"></a>    throw Error(&#39;Illegal thumb element. Neither minThumb nor maxThumb&#39;);
<a name="line784"></a>  }
<a name="line785"></a>};
<a name="line786"></a>
<a name="line787"></a>
<a name="line788"></a>/**
<a name="line789"></a> * Returns whether a thumb is currently being dragged with the mouse (or via
<a name="line790"></a> * touch). Note that changing the value with keyboard, mouswheel, or via
<a name="line791"></a> * move-to-point click immediately sends a CHANGE event without going through a
<a name="line792"></a> * dragged state.
<a name="line793"></a> * @return {boolean} Whether a dragger is currently being dragged.
<a name="line794"></a> */
<a name="line795"></a>goog.ui.SliderBase.prototype.isDragging = function() {
<a name="line796"></a>  return this.valueDragger_.isDragging() || this.extentDragger_.isDragging();
<a name="line797"></a>};
<a name="line798"></a>
<a name="line799"></a>
<a name="line800"></a>/**
<a name="line801"></a> * Moves the thumbs by the specified delta as follows
<a name="line802"></a> * - as long as both thumbs stay within [min,max], both thumbs are moved
<a name="line803"></a> * - once a thumb reaches or exceeds min (or max, respectively), it stays
<a name="line804"></a> * - at min (or max, respectively).
<a name="line805"></a> * In case both thumbs have reached min (or max), no change event will fire.
<a name="line806"></a> * @param {number} delta The delta by which to move the selected range.
<a name="line807"></a> */
<a name="line808"></a>goog.ui.SliderBase.prototype.moveThumbs = function(delta) {
<a name="line809"></a>  var newMinPos = this.getThumbPosition_(this.valueThumb) + delta;
<a name="line810"></a>  var newMaxPos = this.getThumbPosition_(this.extentThumb) + delta;
<a name="line811"></a>  // correct min / max positions to be within bounds
<a name="line812"></a>  newMinPos = goog.math.clamp(
<a name="line813"></a>      newMinPos, this.getMinimum(), this.getMaximum() - this.minExtent_);
<a name="line814"></a>  newMaxPos = goog.math.clamp(
<a name="line815"></a>      newMaxPos, this.getMinimum() + this.minExtent_, this.getMaximum());
<a name="line816"></a>  // Set value and extent atomically
<a name="line817"></a>  this.setValueAndExtent(newMinPos, newMaxPos - newMinPos);
<a name="line818"></a>};
<a name="line819"></a>
<a name="line820"></a>
<a name="line821"></a>/**
<a name="line822"></a> * Sets the position of the given thumb. The set is ignored and no CHANGE event
<a name="line823"></a> * fires if it violates the constraint minimum &lt;= value (valueThumb position) &lt;=
<a name="line824"></a> * value + extent (extentThumb position) &lt;= maximum.
<a name="line825"></a> *
<a name="line826"></a> * Note: To keep things simple, the setThumbPosition_ function does not have the
<a name="line827"></a> * side-effect of &quot;correcting&quot; value or extent to fit the above constraint as it
<a name="line828"></a> * is the case in the underlying range model. Instead, we simply ignore the
<a name="line829"></a> * call. Callers must make these adjustements explicitly if they wish.
<a name="line830"></a> * @param {Element} thumb The thumb whose position to set.
<a name="line831"></a> * @param {number} position The position to move the thumb to.
<a name="line832"></a> * @private
<a name="line833"></a> */
<a name="line834"></a>goog.ui.SliderBase.prototype.setThumbPosition_ = function(thumb, position) {
<a name="line835"></a>  var intermediateExtent = null;
<a name="line836"></a>  // Make sure the maxThumb stays within minThumb &lt;= maxThumb &lt;= maximum
<a name="line837"></a>  if (thumb == this.extentThumb &amp;&amp;
<a name="line838"></a>      position &lt;= this.rangeModel.getMaximum() &amp;&amp;
<a name="line839"></a>      position &gt;= this.rangeModel.getValue() + this.minExtent_) {
<a name="line840"></a>    // For the case where there is only one thumb, we don&#39;t want to set the
<a name="line841"></a>    // extent twice, causing two change events, so delay setting until we know
<a name="line842"></a>    // if there will be a subsequent change.
<a name="line843"></a>    intermediateExtent = position - this.rangeModel.getValue();
<a name="line844"></a>  }
<a name="line845"></a>
<a name="line846"></a>  // Make sure the minThumb stays within minimum &lt;= minThumb &lt;= maxThumb
<a name="line847"></a>  var currentExtent = intermediateExtent || this.rangeModel.getExtent();
<a name="line848"></a>  if (thumb == this.valueThumb &amp;&amp;
<a name="line849"></a>      position &gt;= this.getMinimum() &amp;&amp;
<a name="line850"></a>      position &lt;= this.rangeModel.getValue() +
<a name="line851"></a>          currentExtent - this.minExtent_) {
<a name="line852"></a>    var newExtent = currentExtent -
<a name="line853"></a>                    (position - this.rangeModel.getValue());
<a name="line854"></a>    // The range model will round the value and extent. Since we&#39;re setting
<a name="line855"></a>    // both, extent and value at the same time, it can happen that the
<a name="line856"></a>    // rounded sum of position and extent is not equal to the sum of the
<a name="line857"></a>    // position and extent rounded individually. If this happens, we simply
<a name="line858"></a>    // ignore the update to prevent inconsistent moves of the extent thumb.
<a name="line859"></a>    if (this.rangeModel.roundToStepWithMin(position) +
<a name="line860"></a>            this.rangeModel.roundToStepWithMin(newExtent) ==
<a name="line861"></a>        this.rangeModel.roundToStepWithMin(position + newExtent)) {
<a name="line862"></a>      // Atomically update the position and extent.
<a name="line863"></a>      this.setValueAndExtent(position, newExtent);
<a name="line864"></a>      intermediateExtent = null;
<a name="line865"></a>    }
<a name="line866"></a>  }
<a name="line867"></a>
<a name="line868"></a>  // Need to be able to set extent to 0.
<a name="line869"></a>  if (intermediateExtent != null) {
<a name="line870"></a>    this.rangeModel.setExtent(intermediateExtent);
<a name="line871"></a>  }
<a name="line872"></a>};
<a name="line873"></a>
<a name="line874"></a>
<a name="line875"></a>/**
<a name="line876"></a> * Sets the value and extent of the underlying range model. We enforce that
<a name="line877"></a> * getMinimum() &lt;= value &lt;= getMaximum() - extent and
<a name="line878"></a> * getMinExtent &lt;= extent &lt;= getMaximum() - getValue()
<a name="line879"></a> * If this is not satisifed for the given extent, the call is ignored and no
<a name="line880"></a> * CHANGE event fires. This is a utility method to allow setting the thumbs
<a name="line881"></a> * simultaneously and ensuring that only one event fires.
<a name="line882"></a> * @param {number} value The value to which to set the value.
<a name="line883"></a> * @param {number} extent The value to which to set the extent.
<a name="line884"></a> */
<a name="line885"></a>goog.ui.SliderBase.prototype.setValueAndExtent = function(value, extent) {
<a name="line886"></a>  if (this.getMinimum() &lt;= value &amp;&amp;
<a name="line887"></a>      value &lt;= this.getMaximum() - extent &amp;&amp;
<a name="line888"></a>      this.minExtent_ &lt;= extent &amp;&amp;
<a name="line889"></a>      extent &lt;= this.getMaximum() - value) {
<a name="line890"></a>
<a name="line891"></a>    if (value == this.getValue() &amp;&amp; extent == this.getExtent()) {
<a name="line892"></a>      return;
<a name="line893"></a>    }
<a name="line894"></a>    // because the underlying range model applies adjustements of value
<a name="line895"></a>    // and extent to fit within bounds, we need to reset the extent
<a name="line896"></a>    // first so these adjustements don&#39;t kick in.
<a name="line897"></a>    this.rangeModel.setMute(true);
<a name="line898"></a>    this.rangeModel.setExtent(0);
<a name="line899"></a>    this.rangeModel.setValue(value);
<a name="line900"></a>    this.rangeModel.setExtent(extent);
<a name="line901"></a>    this.rangeModel.setMute(false);
<a name="line902"></a>    this.handleRangeModelChange(null);
<a name="line903"></a>  }
<a name="line904"></a>};
<a name="line905"></a>
<a name="line906"></a>
<a name="line907"></a>/**
<a name="line908"></a> * @return {number} The minimum value.
<a name="line909"></a> */
<a name="line910"></a>goog.ui.SliderBase.prototype.getMinimum = function() {
<a name="line911"></a>  return this.rangeModel.getMinimum();
<a name="line912"></a>};
<a name="line913"></a>
<a name="line914"></a>
<a name="line915"></a>/**
<a name="line916"></a> * Sets the minimum number.
<a name="line917"></a> * @param {number} min The minimum value.
<a name="line918"></a> */
<a name="line919"></a>goog.ui.SliderBase.prototype.setMinimum = function(min) {
<a name="line920"></a>  this.rangeModel.setMinimum(min);
<a name="line921"></a>};
<a name="line922"></a>
<a name="line923"></a>
<a name="line924"></a>/**
<a name="line925"></a> * @return {number} The maximum value.
<a name="line926"></a> */
<a name="line927"></a>goog.ui.SliderBase.prototype.getMaximum = function() {
<a name="line928"></a>  return this.rangeModel.getMaximum();
<a name="line929"></a>};
<a name="line930"></a>
<a name="line931"></a>
<a name="line932"></a>/**
<a name="line933"></a> * Sets the maximum number.
<a name="line934"></a> * @param {number} max The maximum value.
<a name="line935"></a> */
<a name="line936"></a>goog.ui.SliderBase.prototype.setMaximum = function(max) {
<a name="line937"></a>  this.rangeModel.setMaximum(max);
<a name="line938"></a>};
<a name="line939"></a>
<a name="line940"></a>
<a name="line941"></a>/**
<a name="line942"></a> * @return {HTMLDivElement} The value thumb element.
<a name="line943"></a> */
<a name="line944"></a>goog.ui.SliderBase.prototype.getValueThumb = function() {
<a name="line945"></a>  return this.valueThumb;
<a name="line946"></a>};
<a name="line947"></a>
<a name="line948"></a>
<a name="line949"></a>/**
<a name="line950"></a> * @return {HTMLDivElement} The extent thumb element.
<a name="line951"></a> */
<a name="line952"></a>goog.ui.SliderBase.prototype.getExtentThumb = function() {
<a name="line953"></a>  return this.extentThumb;
<a name="line954"></a>};
<a name="line955"></a>
<a name="line956"></a>
<a name="line957"></a>/**
<a name="line958"></a> * @param {number} position The position to get the closest thumb to.
<a name="line959"></a> * @return {HTMLDivElement} The thumb that is closest to the given position.
<a name="line960"></a> * @private
<a name="line961"></a> */
<a name="line962"></a>goog.ui.SliderBase.prototype.getClosestThumb_ = function(position) {
<a name="line963"></a>  if (position &lt;= (this.rangeModel.getValue() +
<a name="line964"></a>                   this.rangeModel.getExtent() / 2)) {
<a name="line965"></a>    return this.valueThumb;
<a name="line966"></a>  } else {
<a name="line967"></a>    return this.extentThumb;
<a name="line968"></a>  }
<a name="line969"></a>};
<a name="line970"></a>
<a name="line971"></a>
<a name="line972"></a>/**
<a name="line973"></a> * Call back when the internal range model changes. Sub-classes may override
<a name="line974"></a> * and re-enter this method to update a11y state. Consider protected.
<a name="line975"></a> * @param {goog.events.Event} e The event object.
<a name="line976"></a> * @protected
<a name="line977"></a> */
<a name="line978"></a>goog.ui.SliderBase.prototype.handleRangeModelChange = function(e) {
<a name="line979"></a>  this.updateUi_();
<a name="line980"></a>  this.updateAriaStates();
<a name="line981"></a>  this.dispatchEvent(goog.ui.Component.EventType.CHANGE);
<a name="line982"></a>};
<a name="line983"></a>
<a name="line984"></a>
<a name="line985"></a>/**
<a name="line986"></a> * This is called when we need to update the size of the thumb. This happens
<a name="line987"></a> * when first created as well as when the value and the orientation changes.
<a name="line988"></a> * @private
<a name="line989"></a> */
<a name="line990"></a>goog.ui.SliderBase.prototype.updateUi_ = function() {
<a name="line991"></a>  if (this.valueThumb &amp;&amp; !this.isAnimating_) {
<a name="line992"></a>    var minCoord = this.getThumbCoordinateForValue(
<a name="line993"></a>        this.getThumbPosition_(this.valueThumb));
<a name="line994"></a>    var maxCoord = this.getThumbCoordinateForValue(
<a name="line995"></a>        this.getThumbPosition_(this.extentThumb));
<a name="line996"></a>
<a name="line997"></a>    if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line998"></a>      this.valueThumb.style.top = minCoord.y + &#39;px&#39;;
<a name="line999"></a>      this.extentThumb.style.top = maxCoord.y + &#39;px&#39;;
<a name="line1000"></a>      if (this.rangeHighlight) {
<a name="line1001"></a>        var highlightPositioning = this.calculateRangeHighlightPositioning_(
<a name="line1002"></a>            maxCoord.y, minCoord.y, this.valueThumb.offsetHeight);
<a name="line1003"></a>        this.rangeHighlight.style.top = highlightPositioning.offset + &#39;px&#39;;
<a name="line1004"></a>        this.rangeHighlight.style.height = highlightPositioning.size + &#39;px&#39;;
<a name="line1005"></a>      }
<a name="line1006"></a>    } else {
<a name="line1007"></a>      var pos = (this.flipForRtl_ &amp;&amp; this.isRightToLeft()) ? &#39;right&#39; : &#39;left&#39;;
<a name="line1008"></a>      this.valueThumb.style[pos] = minCoord.x + &#39;px&#39;;
<a name="line1009"></a>      this.extentThumb.style[pos] = maxCoord.x + &#39;px&#39;;
<a name="line1010"></a>      if (this.rangeHighlight) {
<a name="line1011"></a>        var highlightPositioning = this.calculateRangeHighlightPositioning_(
<a name="line1012"></a>            minCoord.x, maxCoord.x, this.valueThumb.offsetWidth);
<a name="line1013"></a>        this.rangeHighlight.style[pos] = highlightPositioning.offset + &#39;px&#39;;
<a name="line1014"></a>        this.rangeHighlight.style.width = highlightPositioning.size + &#39;px&#39;;
<a name="line1015"></a>      }
<a name="line1016"></a>    }
<a name="line1017"></a>  }
<a name="line1018"></a>};
<a name="line1019"></a>
<a name="line1020"></a>
<a name="line1021"></a>/**
<a name="line1022"></a> * Calculates the start position (offset) and size of the range highlight, e.g.
<a name="line1023"></a> * for a horizontal slider, this will return [left, width] for the highlight.
<a name="line1024"></a> * @param {number} firstThumbPos The position of the first thumb along the
<a name="line1025"></a> *     slider axis.
<a name="line1026"></a> * @param {number} secondThumbPos The position of the second thumb along the
<a name="line1027"></a> *     slider axis, must be &gt;= firstThumbPos.
<a name="line1028"></a> * @param {number} thumbSize The size of the thumb, along the slider axis.
<a name="line1029"></a> * @return {{offset: number, size: number}} The positioning parameters for the
<a name="line1030"></a> *     range highlight.
<a name="line1031"></a> * @private
<a name="line1032"></a> */
<a name="line1033"></a>goog.ui.SliderBase.prototype.calculateRangeHighlightPositioning_ = function(
<a name="line1034"></a>    firstThumbPos, secondThumbPos, thumbSize) {
<a name="line1035"></a>  // Highlight is inset by half the thumb size, from the edges of the thumb.
<a name="line1036"></a>  var highlightInset = Math.ceil(thumbSize / 2);
<a name="line1037"></a>  var size = secondThumbPos - firstThumbPos + thumbSize - 2 * highlightInset;
<a name="line1038"></a>  // Don&#39;t return negative size since it causes an error. IE sometimes attempts
<a name="line1039"></a>  // to position the thumbs while slider size is 0, resulting in size &lt; 0 here.
<a name="line1040"></a>  return {
<a name="line1041"></a>    offset: firstThumbPos + highlightInset,
<a name="line1042"></a>    size: Math.max(size, 0)
<a name="line1043"></a>  };
<a name="line1044"></a>};
<a name="line1045"></a>
<a name="line1046"></a>
<a name="line1047"></a>/**
<a name="line1048"></a> * Returns the position to move the handle to for a given value
<a name="line1049"></a> * @param {number} val  The value to get the coordinate for.
<a name="line1050"></a> * @return {goog.math.Coordinate} Coordinate with either x or y set.
<a name="line1051"></a> */
<a name="line1052"></a>goog.ui.SliderBase.prototype.getThumbCoordinateForValue = function(val) {
<a name="line1053"></a>  var coord = new goog.math.Coordinate;
<a name="line1054"></a>  if (this.valueThumb) {
<a name="line1055"></a>    var min = this.getMinimum();
<a name="line1056"></a>    var max = this.getMaximum();
<a name="line1057"></a>
<a name="line1058"></a>    // This check ensures the ratio never take NaN value, which is possible when
<a name="line1059"></a>    // the slider min &amp; max are same numbers (i.e. 1).
<a name="line1060"></a>    var ratio = (val == min &amp;&amp; min == max) ? 0 : (val - min) / (max - min);
<a name="line1061"></a>
<a name="line1062"></a>    if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line1063"></a>      var thumbHeight = this.valueThumb.offsetHeight;
<a name="line1064"></a>      var h = this.getElement().clientHeight - thumbHeight;
<a name="line1065"></a>      var bottom = Math.round(ratio * h);
<a name="line1066"></a>      coord.x = this.getOffsetStart_(this.valueThumb); // Keep x the same.
<a name="line1067"></a>      coord.y = h - bottom;
<a name="line1068"></a>    } else {
<a name="line1069"></a>      var w = this.getElement().clientWidth - this.valueThumb.offsetWidth;
<a name="line1070"></a>      var left = Math.round(ratio * w);
<a name="line1071"></a>      coord.x = left;
<a name="line1072"></a>      coord.y = this.valueThumb.offsetTop; // Keep y the same.
<a name="line1073"></a>    }
<a name="line1074"></a>  }
<a name="line1075"></a>  return coord;
<a name="line1076"></a>};
<a name="line1077"></a>
<a name="line1078"></a>
<a name="line1079"></a>/**
<a name="line1080"></a> * @deprecated Since 25-June-2012. Use public method getThumbCoordinateForValue.
<a name="line1081"></a> * @private
<a name="line1082"></a> */
<a name="line1083"></a>goog.ui.SliderBase.prototype.getThumbCoordinateForValue_ =
<a name="line1084"></a>    goog.ui.SliderBase.prototype.getThumbCoordinateForValue;
<a name="line1085"></a>
<a name="line1086"></a>
<a name="line1087"></a>/**
<a name="line1088"></a> * Sets the value and starts animating the handle towards that position.
<a name="line1089"></a> * @param {number} v Value to set and animate to.
<a name="line1090"></a> */
<a name="line1091"></a>goog.ui.SliderBase.prototype.animatedSetValue = function(v) {
<a name="line1092"></a>  // the value might be out of bounds
<a name="line1093"></a>  v = goog.math.clamp(v, this.getMinimum(), this.getMaximum());
<a name="line1094"></a>
<a name="line1095"></a>  if (this.isAnimating_) {
<a name="line1096"></a>    this.currentAnimation_.stop(true);
<a name="line1097"></a>  }
<a name="line1098"></a>  var animations = new goog.fx.AnimationParallelQueue();
<a name="line1099"></a>  var end;
<a name="line1100"></a>
<a name="line1101"></a>  var thumb = this.getClosestThumb_(v);
<a name="line1102"></a>  var previousValue = this.getValue();
<a name="line1103"></a>  var previousExtent = this.getExtent();
<a name="line1104"></a>  var previousThumbValue = this.getThumbPosition_(thumb);
<a name="line1105"></a>  var previousCoord = this.getThumbCoordinateForValue(previousThumbValue);
<a name="line1106"></a>  var stepSize = this.getStep();
<a name="line1107"></a>
<a name="line1108"></a>  // If the delta is less than a single step, increase it to a step, else the
<a name="line1109"></a>  // range model will reduce it to zero.
<a name="line1110"></a>  if (Math.abs(v - previousThumbValue) &lt; stepSize) {
<a name="line1111"></a>    var delta = v &gt; previousThumbValue ? stepSize : -stepSize;
<a name="line1112"></a>    v = previousThumbValue + delta;
<a name="line1113"></a>
<a name="line1114"></a>    // The resulting value may be out of bounds, sanitize.
<a name="line1115"></a>    v = goog.math.clamp(v, this.getMinimum(), this.getMaximum());
<a name="line1116"></a>  }
<a name="line1117"></a>
<a name="line1118"></a>  this.setThumbPosition_(thumb, v);
<a name="line1119"></a>  var coord = this.getThumbCoordinateForValue(this.getThumbPosition_(thumb));
<a name="line1120"></a>
<a name="line1121"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line1122"></a>    end = [this.getOffsetStart_(thumb), coord.y];
<a name="line1123"></a>  } else {
<a name="line1124"></a>    end = [coord.x, thumb.offsetTop];
<a name="line1125"></a>  }
<a name="line1126"></a>
<a name="line1127"></a>  var slide = new goog.fx.dom.Slide(thumb,
<a name="line1128"></a>      [previousCoord.x, previousCoord.y],
<a name="line1129"></a>      end,
<a name="line1130"></a>      goog.ui.SliderBase.ANIMATION_INTERVAL_);
<a name="line1131"></a>  slide.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line1132"></a>  animations.add(slide);
<a name="line1133"></a>  if (this.rangeHighlight) {
<a name="line1134"></a>    this.addRangeHighlightAnimations_(thumb, previousValue, previousExtent,
<a name="line1135"></a>        coord, animations);
<a name="line1136"></a>  }
<a name="line1137"></a>
<a name="line1138"></a>  // Create additional animations to play if a factory has been set.
<a name="line1139"></a>  if (this.additionalAnimations_) {
<a name="line1140"></a>    var additionalAnimations = this.additionalAnimations_.createAnimations(
<a name="line1141"></a>        previousValue, v, goog.ui.SliderBase.ANIMATION_INTERVAL_);
<a name="line1142"></a>    goog.array.forEach(additionalAnimations, function(animation) {
<a name="line1143"></a>      animations.add(animation);
<a name="line1144"></a>    });
<a name="line1145"></a>  }
<a name="line1146"></a>
<a name="line1147"></a>  this.currentAnimation_ = animations;
<a name="line1148"></a>  this.getHandler().listen(animations, goog.fx.Transition.EventType.END,
<a name="line1149"></a>      this.endAnimation_);
<a name="line1150"></a>
<a name="line1151"></a>  this.isAnimating_ = true;
<a name="line1152"></a>  animations.play(false);
<a name="line1153"></a>};
<a name="line1154"></a>
<a name="line1155"></a>
<a name="line1156"></a>/**
<a name="line1157"></a> * @return {boolean} True if the slider is animating, false otherwise.
<a name="line1158"></a> */
<a name="line1159"></a>goog.ui.SliderBase.prototype.isAnimating = function() {
<a name="line1160"></a>  return this.isAnimating_;
<a name="line1161"></a>};
<a name="line1162"></a>
<a name="line1163"></a>
<a name="line1164"></a>/**
<a name="line1165"></a> * Sets the factory that will be used to create additional animations to be
<a name="line1166"></a> * played when animating to a new value.  These animations can be for any
<a name="line1167"></a> * element and the animations will be played in addition to the default
<a name="line1168"></a> * animation(s).  The animations will also be played in the same parallel queue
<a name="line1169"></a> * ensuring that all animations are played at the same time.
<a name="line1170"></a> * @see #animatedSetValue
<a name="line1171"></a> *
<a name="line1172"></a> * @param {goog.ui.SliderBase.AnimationFactory} factory The animation factory to
<a name="line1173"></a> *     use.  This will not change the default animations played by the slider.
<a name="line1174"></a> *     It will only allow for additional animations.
<a name="line1175"></a> */
<a name="line1176"></a>goog.ui.SliderBase.prototype.setAdditionalAnimations = function(factory) {
<a name="line1177"></a>  this.additionalAnimations_ = factory;
<a name="line1178"></a>};
<a name="line1179"></a>
<a name="line1180"></a>
<a name="line1181"></a>/**
<a name="line1182"></a> * Adds animations for the range highlight element to the animation queue.
<a name="line1183"></a> *
<a name="line1184"></a> * @param {Element} thumb The thumb that&#39;s moving, must be
<a name="line1185"></a> *     either valueThumb or extentThumb.
<a name="line1186"></a> * @param {number} previousValue The previous value of the slider.
<a name="line1187"></a> * @param {number} previousExtent The previous extent of the
<a name="line1188"></a> *     slider.
<a name="line1189"></a> * @param {goog.math.Coordinate} newCoord The new pixel coordinate of the
<a name="line1190"></a> *     thumb that&#39;s moving.
<a name="line1191"></a> * @param {goog.fx.AnimationParallelQueue} animations The animation queue.
<a name="line1192"></a> * @private
<a name="line1193"></a> */
<a name="line1194"></a>goog.ui.SliderBase.prototype.addRangeHighlightAnimations_ = function(thumb,
<a name="line1195"></a>    previousValue, previousExtent, newCoord, animations) {
<a name="line1196"></a>  var previousMinCoord = this.getThumbCoordinateForValue(previousValue);
<a name="line1197"></a>  var previousMaxCoord = this.getThumbCoordinateForValue(
<a name="line1198"></a>      previousValue + previousExtent);
<a name="line1199"></a>  var minCoord = previousMinCoord;
<a name="line1200"></a>  var maxCoord = previousMaxCoord;
<a name="line1201"></a>  if (thumb == this.valueThumb) {
<a name="line1202"></a>    minCoord = newCoord;
<a name="line1203"></a>  } else {
<a name="line1204"></a>    maxCoord = newCoord;
<a name="line1205"></a>  }
<a name="line1206"></a>
<a name="line1207"></a>  if (this.orientation_ == goog.ui.SliderBase.Orientation.VERTICAL) {
<a name="line1208"></a>    var previousHighlightPositioning = this.calculateRangeHighlightPositioning_(
<a name="line1209"></a>        previousMaxCoord.y, previousMinCoord.y, this.valueThumb.offsetHeight);
<a name="line1210"></a>    var highlightPositioning = this.calculateRangeHighlightPositioning_(
<a name="line1211"></a>        maxCoord.y, minCoord.y, this.valueThumb.offsetHeight);
<a name="line1212"></a>    var slide = new goog.fx.dom.Slide(this.rangeHighlight,
<a name="line1213"></a>        [this.getOffsetStart_(this.rangeHighlight),
<a name="line1214"></a>          previousHighlightPositioning.offset],
<a name="line1215"></a>        [this.getOffsetStart_(this.rangeHighlight),
<a name="line1216"></a>          highlightPositioning.offset],
<a name="line1217"></a>        goog.ui.SliderBase.ANIMATION_INTERVAL_);
<a name="line1218"></a>    var resizeHeight = new goog.fx.dom.ResizeHeight(this.rangeHighlight,
<a name="line1219"></a>        previousHighlightPositioning.size, highlightPositioning.size,
<a name="line1220"></a>        goog.ui.SliderBase.ANIMATION_INTERVAL_);
<a name="line1221"></a>    slide.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line1222"></a>    resizeHeight.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line1223"></a>    animations.add(slide);
<a name="line1224"></a>    animations.add(resizeHeight);
<a name="line1225"></a>  } else {
<a name="line1226"></a>    var previousHighlightPositioning = this.calculateRangeHighlightPositioning_(
<a name="line1227"></a>        previousMinCoord.x, previousMaxCoord.x, this.valueThumb.offsetWidth);
<a name="line1228"></a>    var highlightPositioning = this.calculateRangeHighlightPositioning_(
<a name="line1229"></a>        minCoord.x, maxCoord.x, this.valueThumb.offsetWidth);
<a name="line1230"></a>    var newWidth = highlightPositioning[1];
<a name="line1231"></a>    var slide = new goog.fx.dom.Slide(this.rangeHighlight,
<a name="line1232"></a>        [previousHighlightPositioning.offset, this.rangeHighlight.offsetTop],
<a name="line1233"></a>        [highlightPositioning.offset, this.rangeHighlight.offsetTop],
<a name="line1234"></a>        goog.ui.SliderBase.ANIMATION_INTERVAL_);
<a name="line1235"></a>    var resizeWidth = new goog.fx.dom.ResizeWidth(this.rangeHighlight,
<a name="line1236"></a>        previousHighlightPositioning.size, highlightPositioning.size,
<a name="line1237"></a>        goog.ui.SliderBase.ANIMATION_INTERVAL_);
<a name="line1238"></a>    slide.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line1239"></a>    resizeWidth.enableRightPositioningForRtl(this.flipForRtl_);
<a name="line1240"></a>    animations.add(slide);
<a name="line1241"></a>    animations.add(resizeWidth);
<a name="line1242"></a>  }
<a name="line1243"></a>};
<a name="line1244"></a>
<a name="line1245"></a>
<a name="line1246"></a>/**
<a name="line1247"></a> * Sets the isAnimating_ field to false once the animation is done.
<a name="line1248"></a> * @param {goog.fx.AnimationEvent} e Event object passed by the animation
<a name="line1249"></a> *     object.
<a name="line1250"></a> * @private
<a name="line1251"></a> */
<a name="line1252"></a>goog.ui.SliderBase.prototype.endAnimation_ = function(e) {
<a name="line1253"></a>  this.isAnimating_ = false;
<a name="line1254"></a>};
<a name="line1255"></a>
<a name="line1256"></a>
<a name="line1257"></a>/**
<a name="line1258"></a> * Changes the orientation.
<a name="line1259"></a> * @param {goog.ui.SliderBase.Orientation} orient The orientation.
<a name="line1260"></a> */
<a name="line1261"></a>goog.ui.SliderBase.prototype.setOrientation = function(orient) {
<a name="line1262"></a>  if (this.orientation_ != orient) {
<a name="line1263"></a>    var oldCss = this.getCssClass(this.orientation_);
<a name="line1264"></a>    var newCss = this.getCssClass(orient);
<a name="line1265"></a>    this.orientation_ = orient;
<a name="line1266"></a>
<a name="line1267"></a>    // Update the DOM
<a name="line1268"></a>    if (this.getElement()) {
<a name="line1269"></a>      goog.dom.classes.swap(this.getElement(), oldCss, newCss);
<a name="line1270"></a>      // we need to reset the left and top, plus range highlight
<a name="line1271"></a>      var pos = (this.flipForRtl_ &amp;&amp; this.isRightToLeft()) ? &#39;right&#39; : &#39;left&#39;;
<a name="line1272"></a>      this.valueThumb.style[pos] = this.valueThumb.style.top = &#39;&#39;;
<a name="line1273"></a>      this.extentThumb.style[pos] = this.extentThumb.style.top = &#39;&#39;;
<a name="line1274"></a>      if (this.rangeHighlight) {
<a name="line1275"></a>        this.rangeHighlight.style[pos] = this.rangeHighlight.style.top = &#39;&#39;;
<a name="line1276"></a>        this.rangeHighlight.style.width = this.rangeHighlight.style.height = &#39;&#39;;
<a name="line1277"></a>      }
<a name="line1278"></a>      this.updateUi_();
<a name="line1279"></a>    }
<a name="line1280"></a>  }
<a name="line1281"></a>};
<a name="line1282"></a>
<a name="line1283"></a>
<a name="line1284"></a>/**
<a name="line1285"></a> * @return {goog.ui.SliderBase.Orientation} the orientation of the slider.
<a name="line1286"></a> */
<a name="line1287"></a>goog.ui.SliderBase.prototype.getOrientation = function() {
<a name="line1288"></a>  return this.orientation_;
<a name="line1289"></a>};
<a name="line1290"></a>
<a name="line1291"></a>
<a name="line1292"></a>/** @override */
<a name="line1293"></a>goog.ui.SliderBase.prototype.disposeInternal = function() {
<a name="line1294"></a>  goog.ui.SliderBase.superClass_.disposeInternal.call(this);
<a name="line1295"></a>  if (this.incTimer_) {
<a name="line1296"></a>    this.incTimer_.dispose();
<a name="line1297"></a>  }
<a name="line1298"></a>  delete this.incTimer_;
<a name="line1299"></a>  if (this.currentAnimation_) {
<a name="line1300"></a>    this.currentAnimation_.dispose();
<a name="line1301"></a>  }
<a name="line1302"></a>  delete this.currentAnimation_;
<a name="line1303"></a>  delete this.valueThumb;
<a name="line1304"></a>  delete this.extentThumb;
<a name="line1305"></a>  if (this.rangeHighlight) {
<a name="line1306"></a>    delete this.rangeHighlight;
<a name="line1307"></a>  }
<a name="line1308"></a>  this.rangeModel.dispose();
<a name="line1309"></a>  delete this.rangeModel;
<a name="line1310"></a>  if (this.keyHandler_) {
<a name="line1311"></a>    this.keyHandler_.dispose();
<a name="line1312"></a>    delete this.keyHandler_;
<a name="line1313"></a>  }
<a name="line1314"></a>  if (this.mouseWheelHandler_) {
<a name="line1315"></a>    this.mouseWheelHandler_.dispose();
<a name="line1316"></a>    delete this.mouseWheelHandler_;
<a name="line1317"></a>  }
<a name="line1318"></a>  if (this.valueDragger_) {
<a name="line1319"></a>    this.valueDragger_.dispose();
<a name="line1320"></a>    delete this.valueDragger_;
<a name="line1321"></a>  }
<a name="line1322"></a>  if (this.extentDragger_) {
<a name="line1323"></a>    this.extentDragger_.dispose();
<a name="line1324"></a>    delete this.extentDragger_;
<a name="line1325"></a>  }
<a name="line1326"></a>};
<a name="line1327"></a>
<a name="line1328"></a>
<a name="line1329"></a>/**
<a name="line1330"></a> * @return {number} The amount to increment/decrement for page up/down as well
<a name="line1331"></a> *     as when holding down the mouse button on the background.
<a name="line1332"></a> */
<a name="line1333"></a>goog.ui.SliderBase.prototype.getBlockIncrement = function() {
<a name="line1334"></a>  return this.blockIncrement_;
<a name="line1335"></a>};
<a name="line1336"></a>
<a name="line1337"></a>
<a name="line1338"></a>/**
<a name="line1339"></a> * Sets the amount to increment/decrement for page up/down as well as when
<a name="line1340"></a> * holding down the mouse button on the background.
<a name="line1341"></a> *
<a name="line1342"></a> * @param {number} value The value to set the block increment to.
<a name="line1343"></a> */
<a name="line1344"></a>goog.ui.SliderBase.prototype.setBlockIncrement = function(value) {
<a name="line1345"></a>  this.blockIncrement_ = value;
<a name="line1346"></a>};
<a name="line1347"></a>
<a name="line1348"></a>
<a name="line1349"></a>/**
<a name="line1350"></a> * Sets the minimal value that the extent may have.
<a name="line1351"></a> *
<a name="line1352"></a> * @param {number} value The minimal value for the extent.
<a name="line1353"></a> */
<a name="line1354"></a>goog.ui.SliderBase.prototype.setMinExtent = function(value) {
<a name="line1355"></a>  this.minExtent_ = value;
<a name="line1356"></a>};
<a name="line1357"></a>
<a name="line1358"></a>
<a name="line1359"></a>/**
<a name="line1360"></a> * The amount to increment/decrement for up, down, left and right arrow keys.
<a name="line1361"></a> * @private
<a name="line1362"></a> * @type {number}
<a name="line1363"></a> */
<a name="line1364"></a>goog.ui.SliderBase.prototype.unitIncrement_ = 1;
<a name="line1365"></a>
<a name="line1366"></a>
<a name="line1367"></a>/**
<a name="line1368"></a> * @return {number} The amount to increment/decrement for up, down, left and
<a name="line1369"></a> *     right arrow keys.
<a name="line1370"></a> */
<a name="line1371"></a>goog.ui.SliderBase.prototype.getUnitIncrement = function() {
<a name="line1372"></a>  return this.unitIncrement_;
<a name="line1373"></a>};
<a name="line1374"></a>
<a name="line1375"></a>
<a name="line1376"></a>/**
<a name="line1377"></a> * Sets the amount to increment/decrement for up, down, left and right arrow
<a name="line1378"></a> * keys.
<a name="line1379"></a> * @param {number} value  The value to set the unit increment to.
<a name="line1380"></a> */
<a name="line1381"></a>goog.ui.SliderBase.prototype.setUnitIncrement = function(value) {
<a name="line1382"></a>  this.unitIncrement_ = value;
<a name="line1383"></a>};
<a name="line1384"></a>
<a name="line1385"></a>
<a name="line1386"></a>/**
<a name="line1387"></a> * @return {?number} The step value used to determine how to round the value.
<a name="line1388"></a> */
<a name="line1389"></a>goog.ui.SliderBase.prototype.getStep = function() {
<a name="line1390"></a>  return this.rangeModel.getStep();
<a name="line1391"></a>};
<a name="line1392"></a>
<a name="line1393"></a>
<a name="line1394"></a>/**
<a name="line1395"></a> * Sets the step value. The step value is used to determine how to round the
<a name="line1396"></a> * value.
<a name="line1397"></a> * @param {?number} step  The step size.
<a name="line1398"></a> */
<a name="line1399"></a>goog.ui.SliderBase.prototype.setStep = function(step) {
<a name="line1400"></a>  this.rangeModel.setStep(step);
<a name="line1401"></a>};
<a name="line1402"></a>
<a name="line1403"></a>
<a name="line1404"></a>/**
<a name="line1405"></a> * @return {boolean} Whether clicking on the backgtround should move directly to
<a name="line1406"></a> *     that point.
<a name="line1407"></a> */
<a name="line1408"></a>goog.ui.SliderBase.prototype.getMoveToPointEnabled = function() {
<a name="line1409"></a>  return this.moveToPointEnabled_;
<a name="line1410"></a>};
<a name="line1411"></a>
<a name="line1412"></a>
<a name="line1413"></a>/**
<a name="line1414"></a> * Sets whether clicking on the background should move directly to that point.
<a name="line1415"></a> * @param {boolean} val Whether clicking on the background should move directly
<a name="line1416"></a> *     to that point.
<a name="line1417"></a> */
<a name="line1418"></a>goog.ui.SliderBase.prototype.setMoveToPointEnabled = function(val) {
<a name="line1419"></a>  this.moveToPointEnabled_ = val;
<a name="line1420"></a>};
<a name="line1421"></a>
<a name="line1422"></a>
<a name="line1423"></a>/**
<a name="line1424"></a> * @return {number} The value of the underlying range model.
<a name="line1425"></a> */
<a name="line1426"></a>goog.ui.SliderBase.prototype.getValue = function() {
<a name="line1427"></a>  return this.rangeModel.getValue();
<a name="line1428"></a>};
<a name="line1429"></a>
<a name="line1430"></a>
<a name="line1431"></a>/**
<a name="line1432"></a> * Sets the value of the underlying range model. We enforce that
<a name="line1433"></a> * getMinimum() &lt;= value &lt;= getMaximum() - getExtent()
<a name="line1434"></a> * If this is not satisifed for the given value, the call is ignored and no
<a name="line1435"></a> * CHANGE event fires.
<a name="line1436"></a> * @param {number} value The value.
<a name="line1437"></a> */
<a name="line1438"></a>goog.ui.SliderBase.prototype.setValue = function(value) {
<a name="line1439"></a>  // Set the position through the thumb method to enforce constraints.
<a name="line1440"></a>  this.setThumbPosition_(this.valueThumb, value);
<a name="line1441"></a>};
<a name="line1442"></a>
<a name="line1443"></a>
<a name="line1444"></a>/**
<a name="line1445"></a> * @return {number} The value of the extent of the underlying range model.
<a name="line1446"></a> */
<a name="line1447"></a>goog.ui.SliderBase.prototype.getExtent = function() {
<a name="line1448"></a>  return this.rangeModel.getExtent();
<a name="line1449"></a>};
<a name="line1450"></a>
<a name="line1451"></a>
<a name="line1452"></a>/**
<a name="line1453"></a> * Sets the extent of the underlying range model. We enforce that
<a name="line1454"></a> * getMinExtent() &lt;= extent &lt;= getMaximum() - getValue()
<a name="line1455"></a> * If this is not satisifed for the given extent, the call is ignored and no
<a name="line1456"></a> * CHANGE event fires.
<a name="line1457"></a> * @param {number} extent The value to which to set the extent.
<a name="line1458"></a> */
<a name="line1459"></a>goog.ui.SliderBase.prototype.setExtent = function(extent) {
<a name="line1460"></a>  // Set the position through the thumb method to enforce constraints.
<a name="line1461"></a>  this.setThumbPosition_(this.extentThumb, (this.rangeModel.getValue() +
<a name="line1462"></a>                                            extent));
<a name="line1463"></a>};
<a name="line1464"></a>
<a name="line1465"></a>
<a name="line1466"></a>/**
<a name="line1467"></a> * Change the visibility of the slider.
<a name="line1468"></a> * You must call this if you had set the slider&#39;s value when it was invisible.
<a name="line1469"></a> * @param {boolean} visible Whether to show the slider.
<a name="line1470"></a> */
<a name="line1471"></a>goog.ui.SliderBase.prototype.setVisible = function(visible) {
<a name="line1472"></a>  goog.style.showElement(this.getElement(), visible);
<a name="line1473"></a>  if (visible) {
<a name="line1474"></a>    this.updateUi_();
<a name="line1475"></a>  }
<a name="line1476"></a>};
<a name="line1477"></a>
<a name="line1478"></a>
<a name="line1479"></a>/**
<a name="line1480"></a> * Set a11y roles and state.
<a name="line1481"></a> * @protected
<a name="line1482"></a> */
<a name="line1483"></a>goog.ui.SliderBase.prototype.setAriaRoles = function() {
<a name="line1484"></a>  var el = this.getElement();
<a name="line1485"></a>  goog.asserts.assert(el,
<a name="line1486"></a>      &#39;The DOM element for the slider base cannot be null.&#39;);
<a name="line1487"></a>  goog.a11y.aria.setRole(el, goog.a11y.aria.Role.SLIDER);
<a name="line1488"></a>  this.updateAriaStates();
<a name="line1489"></a>};
<a name="line1490"></a>
<a name="line1491"></a>
<a name="line1492"></a>/**
<a name="line1493"></a> * Set a11y roles and state when values change.
<a name="line1494"></a> * @protected
<a name="line1495"></a> */
<a name="line1496"></a>goog.ui.SliderBase.prototype.updateAriaStates = function() {
<a name="line1497"></a>  var element = this.getElement();
<a name="line1498"></a>  if (element) {
<a name="line1499"></a>    goog.a11y.aria.setState(element, goog.a11y.aria.State.VALUEMIN,
<a name="line1500"></a>        this.getMinimum());
<a name="line1501"></a>    goog.a11y.aria.setState(element, goog.a11y.aria.State.VALUEMAX,
<a name="line1502"></a>        this.getMaximum());
<a name="line1503"></a>    goog.a11y.aria.setState(element, goog.a11y.aria.State.VALUENOW,
<a name="line1504"></a>        this.getValue());
<a name="line1505"></a>  }
<a name="line1506"></a>};
<a name="line1507"></a>
<a name="line1508"></a>
<a name="line1509"></a>/**
<a name="line1510"></a> * Enables or disables mouse wheel handling for the slider. The mouse wheel
<a name="line1511"></a> * handler enables the user to change the value of slider using a mouse wheel.
<a name="line1512"></a> *
<a name="line1513"></a> * @param {boolean} enable Whether to enable mouse wheel handling.
<a name="line1514"></a> */
<a name="line1515"></a>goog.ui.SliderBase.prototype.setHandleMouseWheel = function(enable) {
<a name="line1516"></a>  if (this.isInDocument() &amp;&amp; enable != this.isHandleMouseWheel()) {
<a name="line1517"></a>    this.enableMouseWheelHandling_(enable);
<a name="line1518"></a>  }
<a name="line1519"></a>
<a name="line1520"></a>  this.isHandleMouseWheel_ = enable;
<a name="line1521"></a>};
<a name="line1522"></a>
<a name="line1523"></a>
<a name="line1524"></a>/**
<a name="line1525"></a> * @return {boolean} Whether the slider handles mousewheel.
<a name="line1526"></a> */
<a name="line1527"></a>goog.ui.SliderBase.prototype.isHandleMouseWheel = function() {
<a name="line1528"></a>  return this.isHandleMouseWheel_;
<a name="line1529"></a>};
<a name="line1530"></a>
<a name="line1531"></a>
<a name="line1532"></a>/**
<a name="line1533"></a> * Enable/Disable mouse wheel handling.
<a name="line1534"></a> * @param {boolean} enable Whether to enable mouse wheel handling.
<a name="line1535"></a> * @private
<a name="line1536"></a> */
<a name="line1537"></a>goog.ui.SliderBase.prototype.enableMouseWheelHandling_ = function(enable) {
<a name="line1538"></a>  if (enable) {
<a name="line1539"></a>    if (!this.mouseWheelHandler_) {
<a name="line1540"></a>      this.mouseWheelHandler_ = new goog.events.MouseWheelHandler(
<a name="line1541"></a>          this.getElement());
<a name="line1542"></a>    }
<a name="line1543"></a>    this.getHandler().listen(this.mouseWheelHandler_,
<a name="line1544"></a>        goog.events.MouseWheelHandler.EventType.MOUSEWHEEL,
<a name="line1545"></a>        this.handleMouseWheel_);
<a name="line1546"></a>  } else {
<a name="line1547"></a>    this.getHandler().unlisten(this.mouseWheelHandler_,
<a name="line1548"></a>        goog.events.MouseWheelHandler.EventType.MOUSEWHEEL,
<a name="line1549"></a>        this.handleMouseWheel_);
<a name="line1550"></a>  }
<a name="line1551"></a>};
<a name="line1552"></a>
<a name="line1553"></a>
<a name="line1554"></a>/**
<a name="line1555"></a> * Enables or disables the slider. A disabled slider will ignore all
<a name="line1556"></a> * user-initiated events. Also fires goog.ui.Component.EventType.ENABLE/DISABLE
<a name="line1557"></a> * event as appropriate.
<a name="line1558"></a> * @param {boolean} enable Whether to enable the slider or not.
<a name="line1559"></a> */
<a name="line1560"></a>goog.ui.SliderBase.prototype.setEnabled = function(enable) {
<a name="line1561"></a>  if (this.enabled_ == enable) {
<a name="line1562"></a>    return;
<a name="line1563"></a>  }
<a name="line1564"></a>
<a name="line1565"></a>  var eventType = enable ?
<a name="line1566"></a>      goog.ui.Component.EventType.ENABLE : goog.ui.Component.EventType.DISABLE;
<a name="line1567"></a>  if (this.dispatchEvent(eventType)) {
<a name="line1568"></a>    this.enabled_ = enable;
<a name="line1569"></a>    this.enableEventHandlers_(enable);
<a name="line1570"></a>    if (!enable) {
<a name="line1571"></a>      // Disabling a slider is equivalent to a mouse up event when the block
<a name="line1572"></a>      // increment (if happening) should be halted and any possible event
<a name="line1573"></a>      // handlers be appropriately unlistened.
<a name="line1574"></a>      this.stopBlockIncrementing_();
<a name="line1575"></a>    }
<a name="line1576"></a>    goog.dom.classes.enable(this.getElement(),
<a name="line1577"></a>        goog.ui.SliderBase.DISABLED_CSS_CLASS_, !enable);
<a name="line1578"></a>  }
<a name="line1579"></a>};
<a name="line1580"></a>
<a name="line1581"></a>
<a name="line1582"></a>/**
<a name="line1583"></a> * @return {boolean} Whether the slider is enabled or not.
<a name="line1584"></a> */
<a name="line1585"></a>goog.ui.SliderBase.prototype.isEnabled = function() {
<a name="line1586"></a>  return this.enabled_;
<a name="line1587"></a>};
<a name="line1588"></a>
<a name="line1589"></a>
<a name="line1590"></a>/**
<a name="line1591"></a> * @param {Element} element An element for which we want offsetLeft.
<a name="line1592"></a> * @return {number} Returns the element&#39;s offsetLeft, accounting for RTL if
<a name="line1593"></a> *     flipForRtl_ is true.
<a name="line1594"></a> * @private
<a name="line1595"></a> */
<a name="line1596"></a>goog.ui.SliderBase.prototype.getOffsetStart_ = function(element) {
<a name="line1597"></a>  return this.flipForRtl_ ?
<a name="line1598"></a>      goog.style.bidi.getOffsetStart(element) : element.offsetLeft;
<a name="line1599"></a>};
<a name="line1600"></a>
<a name="line1601"></a>
<a name="line1602"></a>
<a name="line1603"></a>/**
<a name="line1604"></a> * The factory for creating additional animations to be played when animating to
<a name="line1605"></a> * a new value.
<a name="line1606"></a> * @interface
<a name="line1607"></a> */
<a name="line1608"></a>goog.ui.SliderBase.AnimationFactory = function() {};
<a name="line1609"></a>
<a name="line1610"></a>
<a name="line1611"></a>/**
<a name="line1612"></a> * Creates an additonal animation to play when animating to a new value.
<a name="line1613"></a> *
<a name="line1614"></a> * @param {number} previousValue The previous value (before animation).
<a name="line1615"></a> * @param {number} newValue The new value (after animation).
<a name="line1616"></a> * @param {number} interval The animation interval.
<a name="line1617"></a> * @return {!Array.&lt;!goog.fx.TransitionBase&gt;} The additional animations to play.
<a name="line1618"></a> */
<a name="line1619"></a>goog.ui.SliderBase.AnimationFactory.prototype.createAnimations;
</pre>


</body>
</html>
